package com.aso114.project.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.aso114.project.R;
import com.aso114.project.bean.QuestionBaseBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by asus on 2019/1/17.
 */

public class ExpositionCardAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<QuestionBaseBean> baseBean;

    public ExpositionCardAdapter(Context context, ArrayList<QuestionBaseBean> baseBean) {
        this.context = context;
        this.baseBean = baseBean;
    }

    @Override
    public int getCount() {
        return baseBean.size();
    }

    @Override
    public Object getItem(int position) {
        return baseBean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView != null) {
            holder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(context).inflate(R.layout.circle_img, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder.circleImg.setText((position + 1) + "");
        holder.circleImg.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.circle_default));
        holder.circleImg.setTextColor(context.getResources().getColor(R.color.a333333));
        return convertView;
    }

    public void setData(ArrayList<QuestionBaseBean> baseBean) {
        this.baseBean = baseBean;
    }

    static class ViewHolder {
        @BindView(R.id.circle_img)
        TextView circleImg;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
